<?php

namespace MrHd\LJsTan;

use Illuminate\Foundation\Application;
use Illuminate\Support\ServiceProvider;

class LJsTanServiceProvider extends ServiceProvider
{
    /**
     * @return void
     * 引导所有的应用服务
     */
    public function boot(): void
    {
        if ($this->app instanceof Application && $this->app->runningInConsole()) {
            $this->publishes([
                dirname(__DIR__).'/config/ljsTan.php' => config_path('ljsTan.php'), ],
                'laravel-jushuitan'
            );
        }
    }

    /**
     * @return void
     * 注册所有的应用服务
     */
    public function register(): void
    {
        $this->mergeConfigFrom(dirname(__DIR__).'/config/ljsTan.php', 'ljsTan');
        $this->app->singleton('LJsTanService', function () {
            return Client::getInstance(config('ljsTan'));
        });
    }

    public function provides(): array
    {
        return ['LJsTanService'];
    }

}
